The present invention relates to a tracking method, especially to a tracking method for embedded systems.
Due to fast development of modern technology, processing speed of hardware or software in computer systems has continued to grow, especially for embedded systems. While executing software program, embedded systems consume memory resources. Thus how to effectively use memory is one of key factors that affect processing speed.
In the embedded system, one of the essential services is that a memory is dynamically allocated to a function. When each function makes a request, the embedded system dynamically allocates the memory block to the function. While once the memory block is not required by the function, the memory block consumed is returned to the embedded system. Thus the system resource sharing is achieved. Moreover, when each thread or process is run by a main function, other sub-functions are called to perform other functions according to dynamically external input, system information, or hardware interrupt and the sub-function continuingly calls other functions nestedly according to program logic. In such way with combinations of various functions, program execution is achieved.
During a process compiling the program that a first function calls a second function, the microprocessor learns content of Lth line code in the first function is calling the second function. After finishing compiling, function name and header of the Lth line code in the memory are saved while a first function's executable code corresponding to the first function and a second function's executable code corresponding to the second function are generated. When the embedded system executes the first function's executable code in the Lth line, the execution point of the program jumps to address of the second function's executable code. The second function's executable code is executed from an entry point of the second function.
In accordance with above description, program designers check the header of the memory block to learn the memory block is required by the first function. Therefore, all memory allocation is learned. Furthermore, root causes of system shut-down or program errors are found out by viewing the memory block.
However, while compiling the program, some memory is used to save memory allocation related information. That means function names and Lth line codes are saved. Moreover, when the program is running, memory allocation related information is also needed to be saved in the header of the memory block. Therefore, the memory and time consumed of the embedded system are increased while the processing efficiency is decreased. Thus there is a need to provide a novel tracking method for embedded systems that not only increases processing efficiency of embedded systems but also saves memory. Whiling executing a function, the whole call stack is got so as to learn reason and timing of the function being called.